跳到主要内容

GetRange

Returns a Range object that represents the document part contained in the specified range.

Syntax

expression.GetRange(Start, End);

expression - A variable that represents a ApiRange class.

Parameters

NameRequired/OptionalData typeDefaultDescription
StartOptionalNumberfalseStart position index in the current range.
EndOptionalNumber-1End position index in the current range (if <= 0, then the range is taken to the end).

Returns

ApiRange

Example

This example shows how to get a Range object that represents the document part contained in the specified range.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let range1 = doc.GetRange(0, 24);
range1.SetBold(true);
let range2 = range1.GetRange(0, 9);
range2.SetItalic(true);